* Date: May 19th, 2024

est clear

* Prompt user to enter their file paths
local inputPath = `"`c(pwd)'"'
local outputPath = `"`c(pwd)'"'

* Load dataset (update filename as needed, path can be entered by the user)
local dataFile = "`inputPath'/local_projection.dta"
use "`dataFile'", clear

* Change working directory to output path (update if needed)
cd "`outputPath'"

* Drop specified countries (optional, uncomment if needed)
drop if inlist(country, "China", "Russia") // Exclude specific countries

* Set panel structure (replace identifiers as needed)
xtset iso_num year

* Generate GDP growth
qui gen GDP_growth = (rgdppc - L.rgdppc) / L.rgdppc * 100

* Generate real credit loan and credit growth variables
qui gen rcredit_loan = tloans / cpi
qui gen Credit_growth = (rcredit_loan - L.rcredit_loan) / L.rcredit_loan * 100

* Generate finance sentiment difference and level
qui gen Finance_sentiment_fd = (all_stdscore - L.all_stdscore) * 100
qui gen Finance_sentiment = all_stdscore

* Retain and order relevant variables
keep iso_num year GDP_growth Credit_growth Finance_sentiment_fd
order iso_num year GDP_growth Credit_growth Finance_sentiment_fd

* Save the processed dataset (customize output filename as needed)
local outputDataFile = "`outputPath'/lp_allstd_credit.dta"
save "`outputDataFile'", replace
